package org.yohailong.studyspringboot.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.yohailong.studycommon.pojo.vo.Response;
import org.yohailong.studyspringboot.common.util.ResponseUtil;
import org.yohailong.studyspringboot.pojo.req.DateReq;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 朱海龙
 * 2024/4/28 17:05
 */
@Slf4j
@RestController
@RequestMapping("/demo")
public class DemoController {

    @PostMapping("/uploadDate")
    public Response<Boolean> uploadDate(@RequestBody @Validated DateReq req) {
        Date birthday = req.getBirthday();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = dateFormat.format(birthday);
        log.error("生日为=>{}", format);
        return ResponseUtil.success(null);
    }
}
